#pragma once
#include <d3d11.h>
#pragma comment(lib, "d3d11")
#include <vector>
#include "XTime.h"
#include <DirectXMath.h>
#include "ShaderGroup.h"
#include "D3DMesh.h"
#include "D3DCamera.h"
using namespace DirectX;

#define BACKBUFFER_WIDTH	1440.0f
#define BACKBUFFER_HEIGHT	900.0f

class D3DMesh;

//struct INSTANCE_STRUCT
//{
//	XMFLOAT4X4 worldMatrix;
//
//
//};

class DX_APP
{
private:

	HINSTANCE						application;
	WNDPROC							appWndProc;
	HWND							window;

	// TODO: PART 1 STEP 2
	ID3D11Device* pDevice = 0;
	IDXGISwapChain* pSwapChain = 0;
	ID3D11DeviceContext* pContext = 0;
	ID3D11RenderTargetView* pRenderTargetView = 0;
	D3D11_VIEWPORT viewPort;

	

	ID3D11Texture2D* depthBuffer = 0;
	ID3D11DepthStencilView* pDepthStencilView = 0;
	ID3D11DepthStencilState * depthStencilState = 0;


	ID3D11Buffer* instanceBuffer = 0;



	

	
	
	HRESULT CreateDepthStencilBuffer(void);
public:

	

	//void DrawIndexedMesh(Mesh& mesh, Scene world);
	//void DrawMesh(Mesh& mesh, Scene world);
	
//	D3DMesh* LoadObjMesh(const char* path);
	D3DMesh* CreateStar(void);

	void UpdateSkyBox();
	void UpdateFlashLight();
	

	DX_APP(HINSTANCE hinst, WNDPROC proc);

	void CreateStarInstanceBuffer(unsigned int numInstance);
	void RotateStar();
	
	bool Run();
	bool ShutDown();

	ShaderGroup shaderSet1;
	ShaderGroup starShaders;
	ShaderGroup planeShaders;
	ShaderGroup skyBoxShaders;

	ID3D11RasterizerState* CWCull;
	ID3D11RasterizerState* CCWCull;



	VS_CONSTANT_BUFFER vsCBuffer1;
	VS_CONSTANT_BUFFER vsCBuffer2;
	VS_CONSTANT_BUFFER vsCBuffer3;
	VS_CONSTANT_BUFFER skyBuffer;
	VS_CONSTANT_BUFFER vsCBuffer4;

	DIR_LIGHT_BUFFER dlCBuffer;
	POINT_LIGHT_BUFFER plCBuffer;
	SPOT_LIGHT_BUFFER slCBuffer;



	XTime timer;
	//D3DMesh* cube;
	D3DMesh alien;
	D3DMesh star;
	D3DMesh plane;
	D3DMesh SkyBox;
	D3DMesh odst;



	D3DCamera camera1;
	//D3DMesh* star;
	//D3DMesh* p90;


};

